From: Keir Fraser Date: Mon, 26 Oct 2009 12:18:50 +0000 (+0000) Subject: shadow dirty-VRAM: avoid multiple remove_all_mappings calls. X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~13175 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:/%22bookmarks://%22Dat/%22http:/www.example.com/cgi/%22https:/%22bookmarks:/%22Dat?a=commitdiff_plain;h=02a4e58f0b4a44b6b9ee2d02af1b99700d976fd8;p=xen.git shadow dirty-VRAM: avoid multiple remove_all_mappings calls. sh_remove_all_mappings() will walk roughly half of the shadow L1 tables for each MFN it's called with; calling it for every MFN in a guest's framebuffer can be _very_ expensive, especially with the shadow lock held across the whole operation. Avoid that by just blowing away all the shadows. Signed-off-by: Tim Deegan --- diff --git a/xen/arch/x86/mm/shadow/common.c b/xen/arch/x86/mm/shadow/common.c index 577d97a696..becf32566f 100644 --- a/xen/arch/x86/mm/shadow/common.c +++ b/xen/arch/x86/mm/shadow/common.c @@ -3637,12 +3637,9 @@ int shadow_track_dirty_vram(struct domain *d, * no need to be careful. */ if ( !dirty_vram ) { - /* Just recount from start. */ - for ( i = begin_pfn; i < end_pfn; i++ ) { - mfn_t mfn = gfn_to_mfn(d, i, &t); - if (mfn_x(mfn) != INVALID_MFN) - flush_tlb |= sh_remove_all_mappings(d->vcpu[0], mfn); - } + /* Throw away all the shadows rather than walking through them + * up to nr times getting rid of mappings of each pfn */ + shadow_blow_tables(d); gdprintk(XENLOG_INFO, "tracking VRAM %lx - %lx\n", begin_pfn, end_pfn);